<p>
 第一步是粗略和精细集合选择。通过粗选，我们创建了一个包含所有在纽交所、美国证券交易所和纳斯达克上市的非金融类美国股票的投资领域，这些股票都包含基本数据。这一集合将被保存下来，这样我们就可以对下一年中总资产的年度变化进行分析。
</p>
<div class="section-example-container">
<pre class="python">
def CoarseSelectionFunction(self, coarse):
        if self.yearly_rebalance:
            filtered_coarse = [x.Symbol for x in coarse if (x.HasFundamentalData)
                                                            and (x.Market == "usa")]
            return filtered_coarse
        else: 
            return []

def FineSelectionFunction(self, fine):
    if self.yearly_rebalance:
        fine = [x for x in fine if x.FinancialStatements.BalanceSheet.TotalAssets.Value > 0
                and ((x.SecurityReference.ExchangeId == "NYS") or (x.SecurityReference.ExchangeId == "NAS") or (x.SecurityReference.ExchangeId == "ASE"))
                and (x.CompanyReference.IndustryTemplateCode!="B")
                and (x.CompanyReference.IndustryTemplateCode!="I")]
        if not self.previous_fine:
            self.previous_fine = fine
            self.yearly_rebalance = False
            return []
        else:
            self.filtered_fine = self.Calculate(fine,self.previous_fine)
            sorted_filter = sorted(self.filtered_fine, key=lambda x: x.delta_assets)
            self.filtered_fine = [i.Symbol for i in sorted_filter]
            self.previous_fine = fine
            return self.filtered_fine
    else:
        return []
</pre>
</div>
<p>
  在精细集合选择中，我们从上一年和当年的股票中计算出它们的总资产增长。然后根据采用的计算按照升序对股票进行排序。要注意的是，我们通过去年总资产的增长比例来计算样本公司之间的规模差异。
</p>
<div class="section-example-container">
<pre class="python">
def Calculate(self, current, previous):
        growth = []
        for stock_data in current:
            try:
                prev_data = None
                for x in previous:
                    if x.Symbol == stock_data.Symbol:
                        prev_data = x
                        break
                stock_data.delta_assets = (float(stock_data.FinancialStatements.BalanceSheet.TotalAssets.Value)-float(prev_data.FinancialStatements.BalanceSheet.TotalAssets.Value))/float(prev_data.FinancialStatements.BalanceSheet.TotalAssets.Value) 
                growth.append(stock_data)
            except:
                pass
        return growth
</pre>
</div>
<p>
   在<code>OnData()</code>中，我们做空排序列表中前百分之十的股票，做多后百分之十的股票。投资组合每年会在6月底重新调整。
</p>
